﻿using NRank.Common;

namespace NRank.Algorithms.Strategies
{
	/// <summary>
	/// Pulling strategy which chooses input, after which reading next item will lower the threshold.
	/// </summary>
	internal class ThresholdMinimizePullingStrategy : IPullingStrategy
	{
		/// <summary>
		/// Threshold counter
		/// </summary>
		private readonly ThresholdCounter thresholdCounter;

		/// <summary>
		/// Creates instance of ThresholdMinimizePullingStrategy.
		/// </summary>
		/// <param name="thresholdCounter">Threshold counter</param>
		public ThresholdMinimizePullingStrategy(ThresholdCounter thresholdCounter)
		{
			this.thresholdCounter = thresholdCounter;
		}

		/// <summary>
		/// Decides if algorithm should pull item from left input when it can.
		/// </summary>
		public bool CanPullLeft
		{
			get { return thresholdCounter.IsLeftMinBlockingThreshold(); }
		}

		/// <summary>
		/// Decides if algorithm should pull item from right input when it can.
		/// </summary>
		public bool CanPullRight
		{
			get { return thresholdCounter.IsRightMinBlockingThreshold(); }
		}
	}
}